package com.demo.java.spring.validation;

import org.apache.commons.lang3.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class NameValidator implements ConstraintValidator<NameValid, String> {
    @Override
    public void initialize(NameValid constraintAnnotation) {}

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        System.out.println("username valid");
        boolean valid = StringUtils.isNoneBlank(s);
        System.out.println("valid: " + valid);
        return valid;
    }
}
